package com.example.ruiji.controller;

import com.example.ruiji.common.Result;
import com.example.ruiji.entity.ShoppingCart;
import com.example.ruiji.service.ShoppingCartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/shoppingCart")
public class ShoppingCartController {

    @Autowired
    private ShoppingCartService shoppingCartService;

    @PostMapping("/add")
    public Result<ShoppingCart> add(@RequestBody ShoppingCart shoppingCart) {
        return shoppingCartService.add(shoppingCart);
    }

    @GetMapping("/list")
    public Result<List<ShoppingCart>> list() {
        return shoppingCartService.list();
    }

    @DeleteMapping("clean")
    public Result<String> clean() {
        return shoppingCartService.clean();
    }
}
